home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d22 / csap208b.arc / GETDPB.C < prev    next >
Text File  |  1989-10-10  |  2KB  |  45 lines

  1. #include <stdio.h>
  2. #include <dos.h>
  3. #include "dosstruc.h"
  4.  
  5. /*
  6.  *    GETDPB is a routine to use the undocumented PC/MS-DOS Int 21H, Func 32H
  7.  *           to obtain disk information.  This function has been verified to
  8.  *           perform correctly in all versions of PC/MS-DOS from 2.0 through
  9.  *           3.3.  Since it is heavily used by DOS programs such as CHKDSK,
  10.  *           it will prbably continue to work correctly.  This routine is used
  11.  *           to avoid problems with non-standard boot sectors.
  12.  */
  13.  
  14. void GetDPB (int Disk, struct DpbStruct *Dpb) {
  15.     int seg, offset;
  16.  
  17.     offset = FP_OFF(Dpb);        /* Separate ptr to return area into Seg */
  18.     seg = FP_SEG(Dpb);            /*   and Offset                            */
  19.     asm test    word ptr seg,0FFFFH        /* Compensate for "Tiny" model            */
  20.     asm jnz        L0
  21.     asm mov        seg,DS
  22. L0:
  23.     asm push    ES                /* Save ES and DS for return            */
  24.     asm push    DS
  25.     asm mov     DX,Disk           /* Get disk number for func 32H      */
  26.     asm test    DL,0FFH           /* Check for default disk               */
  27.     asm jz      L1                /* ... Xfr - default                   */
  28.     asm and     DL,0FH            /* Make disk numeric                   */
  29. L1:
  30.     asm mov     AH,32H            /* MS-DOS 'Get Disk Parameter Block' */
  31.     asm int     21H               /* ... DOS Entry Interrupt           */
  32.     asm mov     SI,BX             /* DS:SI points to parameter block   */
  33.     asm mov     DI,offset         /* ES:DI points to destination       */
  34.     asm mov        ES,seg              /* ...                               */
  35.     asm mov     CX,28             /* CX = size of block                   */
  36.     asm cld                       /* Clear Direction Flag [forward]       */
  37.     asm rep     movsb             /* Move parameter block               */
  38.     asm pop        DS
  39.     asm pop        ES
  40.     }
  41.  
  42.  
  43.  
  44.  
  45.